<template>
<div>
 <BaseSearch :formItemList="formItemList" :emitSearch="emitSearch"  @search="search" />

<BaseSearch :formItemList="formItemList" @search="search" ></BaseSearch >
</div>

</template>

<script>
import BaseSearch from '@/components/Search/Search.vue'
export default {
  components: {
    BaseSearch
  },
  data () {
    return {
      dialogVisible: false,
      emitSearch: true,
      formItemList: [
        {
          label: '所属单位',
          type: 'select',
          selectOptions: [{ name: 111, value: 111 }],
          param: 'company'
        },
        {
          label: '化学品名称',
          type: 'input',
          param: 'name'
        },
        {
          label: '是否停用企业',
          type: 'select',
          selectOptions: [{ name: 111, value: 111 }],
          param: 'stop'
        },
        {
          label: '下拉框222',
          type: 'select',
          selectOptions: [{ name: 111, value: 111 }],
          param: 'parm222'
        }
      ]

    }
  },
  mounted () {
    this.so()
    // 此时请求下拉框的数据接口
    // axios。。。。
    //  this.formItemList[3].selectOptions = res.data
    // 其他下拉框的选项赋值
    //  这里判断 是否立即执行搜索
    // 全部下拉框的数据都塞进去后执行搜索
    // this.emitSearch=true
  },
  methods: {
    searchTableList (params) {
      console.log(params)
    },
    handleOpen (typeVal) {
      this.dialogVisible = true
      this.formItemList[3].defaultSelect = typeVal || '' // 打开弹窗时下拉框赋默认选中的值
      this.emitSearch = true
    },
    handleClose (done) {
      this.dialogVisible = false
    },
    search (params) { // 搜索条件改变时
      this.searchTableList(params)
    },
    so () {
      const newArr = [{ a: 0 }, { a: 1 }]
      const result = newArr.every((val) => val.a === 0)
      console.log(result)
    }
  }
}
</script>
